home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17281 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.5 KB  |  144 lines

  1. Path: news.crd.ge.com!rebecca!news
  2. From: Helin Wei <whl@climate.asrc.albany.edu>
  3. Newsgroups: comp.lang.c++
  4. Subject: help need in rewriting the code from c to c++
  5. Date: Sun, 14 Apr 1996 21:17:56 -0400
  6. Organization: The University at Albany
  7. Message-ID: <3171A3C3.799@climate.asrc.albany.edu>
  8. NNTP-Posting-Host: csss1.climate.asrc.albany.edu
  9. Mime-Version: 1.0
  10. Content-Type: multipart/mixed; boundary="------------C5C411870FA"
  11. X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.4 sun4c)
  12.  
  13. This is a multi-part message in MIME format.
  14.  
  15. --------------C5C411870FA
  16. Content-Type: text/plain; charset=gb2312
  17. Content-Transfer-Encoding: 7bit
  18.  
  19. Anyone can help me rewrite the following code in c++,I'd appreciate
  20. if he can mail the result to whl@climate.asrc.albany.edu.Thanks.
  21.  
  22. --------------C5C411870FA
  23. Content-Type: text/plain; charset=gb2312
  24. Content-Transfer-Encoding: 7bit
  25. Content-Disposition: inline; filename="signal.c"
  26.  
  27. /*--------------------------------------------------------------------*/
  28.  
  29. #ifdef sun
  30.  
  31. #include <signal.h>
  32. #include <stdio.h>
  33. #define SUN
  34.  
  35. void stopgf_();
  36.  
  37. void setsig_()
  38. {    /*  set up to catch a few signals  */
  39.  
  40. #include <floatingpoint.h>
  41.   void sgsegv(), sgbuserr();
  42.   void sginexact(), sg0div(), sgunder(), sgover(), sginvalid();
  43.   struct sigvec sigsegv, sigbus;
  44.   extern int sigvec(), ieee_handler();
  45.  
  46.   sigsegv.sv_handler = sgsegv;
  47.   sigbus.sv_handler = sgbuserr;
  48.   (void) sigvec(SIGSEGV, &sigsegv, NULL);
  49.   (void) sigvec(SIGBUS, &sigbus, NULL);
  50. /*ieee_handler("set", "inexact", sginexact);*/
  51.   ieee_handler("set", "division", sg0div); 
  52.   ieee_handler("set", "underflow", sgunder);
  53.   ieee_handler("set", "overflow", sgover);
  54.   ieee_handler("set", "invalid", sginvalid);
  55.  
  56.  return;
  57. }
  58.  
  59.  
  60. /*  Signal handlers follow  */
  61.  
  62.  
  63. void sgsegv()
  64. {
  65.   printf("Segmentation violation");
  66.   stopgf_();
  67. }
  68.  
  69.  
  70. void sgbuserr()
  71. {
  72.   printf("Bus error");
  73.   stopgf_();
  74. }
  75.  
  76.  
  77. void sginexact()
  78. {
  79.   printf("Inexact FPE error");
  80.   stopgf_();
  81. }
  82.  
  83.  
  84. void sg0div()
  85. {
  86.   printf("Division by zero FPE error");
  87.   stopgf_();
  88. }
  89.  
  90.  
  91. void sgunder()
  92. {
  93.   printf("Underflow FPE error");
  94.   stopgf_();
  95. }
  96.  
  97.  
  98. void sgover()
  99. {
  100.   printf("Overflow FPE error");
  101.   stopgf_();
  102. }
  103.  
  104.  
  105. void sginvalid()
  106. {
  107.   printf("Invalid FPE error");
  108.   stopgf_();
  109. }
  110.  
  111.  
  112. void stopgf_()
  113. {
  114.    printf("\nstopgf_() called\n");
  115.    abort();
  116. }
  117.  
  118. #endif
  119.  
  120. /*--------------------------------------------------------------------*/
  121.  
  122. #ifdef sgi
  123.  
  124. void setsig_()
  125. {
  126. }
  127.  
  128. #endif
  129.  
  130. /*--------------------------------------------------------------------*/
  131.  
  132. #ifdef cray
  133.  
  134. void SETSIG()
  135. {
  136. }
  137.  
  138. #endif
  139.  
  140. /*--------------------------------------------------------------------*/
  141.  
  142. --------------C5C411870FA--
  143.  
  144.